import json

import requests

if __name__ == '__main__':
    url = 'https://movie.douban.com/j/search_subjects'

    param = {
        'type': ' movie',
        'tag': ' 热门',
        'sort': ' recommend',
        'page_limit': ' 20',
        'page_start': ' 40',
    }
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36'
    }
    response = requests.get(url=url, params=param, headers=headers)
    list_data = response.json()

    fp = open('./douban.json', 'w', encoding='utf-8')
    json.dump(list_data, fp=fp, ensure_ascii=False)
    print('over')